<?php
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
    include "../../config.php";


// 从请求中获取参数并赋值
$task['ai_step'] = $_REQUEST['step'];
$task['ai_status'] = $_REQUEST['status'];
$task['ai_remark'] = $_REQUEST['remark'];

    if($_REQUEST['step']=='start')
    {
        $task['ai_task'] = $_REQUEST['task'];
        $task['ai_account'] = $_REQUEST['account'];
        //插入数据
        //执行语句
        $_sql=insert_data($table_prefix."dashboard_task_log",$task);
        mysql_query($_sql) or die("Error: " . mysql_error().$_sql);

        //返回刚才插入的数据的nid
        $result['nid']=mysql_insert_id();
        $result['status'] = 'success';
        $result['message'] = 'Task start record successfully';


    }
    elseif($_REQUEST['step']=='end')
    {
        //更新数据
        //执行语句
        $_sql=update_date($table_prefix."dashboard_task_log",$task,"nid",$_REQUEST['nid']);
        mysql_query($_sql) or die("Error: " . mysql_error().$_sql);

        // 返回成功结果
        $result['status'] = 'success';
        $result['message'] = 'Task updated successfully';


    }


// 返回JSON格式的结果
header('Content-Type: application/json');
echo json_encode($result);



?>
